<template>
    <div>
        <h1 style="text-align: center; color: aqua;">修改员工数据</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>员工名称</td>
                    <td>
      
                        <span>{{info.HouseName}}</span>
                    </td>
                </tr>
                <tr>
                    <td>员工编号</td>
                    <td>
                       
                        <span>{{info.Bianhao}}</span>
                    </td>
                </tr>
                <tr>
                    <td>头像</td>
                    <td>
                        <img :src="info.Touxiang" width="100" height="100" v-if="info.Touxiang!=''">
                    </td>
                </tr>
                <tr>
                    <td>手机号</td>
                    <td>
               
                        <span>{{info.Shouji}}</span>
                    </td>
                </tr>
                <tr>
                    <td>角色</td>
                    <td>
                            <span>
                            <td v-if="info.Juese==1">
                                管理员
                            </td>
                            <td v-if="info.Juese==2">
                                部门经理
                            </td>
                            <td v-if="info.Juese==3">
                                普通员工
                            </td>
                     
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>登录密码</td>
                    <td>
                       
                        <span>*****</span>
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <span>{{info.Zhungtai==true?'启用':'禁用'}}</span>
                    </td>
                </tr>
                <tr>
                    <td>备注</td>
                    <td>
                        <span>{{info.Biezhu}}</span>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>

                        <button class="btn btn-info" @click="router.push('/employeeList')">返回</button>
                    </td>
                </tr>
            </tbody>
        </table>

    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted}from 'vue'
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
import moment from 'moment';
const router=useRouter();
const route=useRoute();

let info:any=reactive({
  "HouseName": "",
  "Bianhao":moment(new Date).format("YYYYMMDD")+Math.random().toString().substring(3,6),
  "Touxiang": "",
  "Shouji": "",
  "Juese": '',
  "Pwd": "",
  "Zhungtai": true,
  "Biezhu": "",
})

onMounted(()=>{
    fantian()
})


//反填
const fantian=()=>{
    console.log(info);

    axios({
        url:'/api/Employee/Fantian',
        method:'get',
        params:{
            id:route.query.id
        }
    }).then(res=>{
        console.log(res);
        Object.assign(info,res.data)
        
    }).catch(err=>{
        console.log(err);
        
    })
    
}


</script>

<style scoped>
button{
    margin: 0 5px;
}
</style>